<template>
  <div>
<<<<<<< HEAD
    1
=======
    <div>

      <el-form :inline="true" :model="dataForm">
        <el-form-item>
          <el-button v-if="isAuth('prod:category:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
        </el-form-item>
      </el-form>
      <el-table :data="dataList" border style="width: 100%;" row-key="categoryId">
        <el-table-column prop="categoryName" header-align="center" treeKey="categoryId" width="150" label="分类名称">
        </el-table-column>
        <el-table-column header-align="center" align="center" label="图片">
          
           <img src="" alt="" srcset="">
            <!-- <image src="scope.row.pic"></image> -->
       
        </el-table-column>
        <el-table-column prop="status" header-align="center" align="center" width="150" :show-overflow-tooltip="true"
          label="状态">
          <el-tag>标签一</el-tag>

        </el-table-column>
        <el-table-column prop="seq" header-align="center" align="center" label="排序号">
        </el-table-column>


        <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
          <template slot-scope="scope">
            <el-button v-if="isAuth('prod:category:update')" type="primary" size="small"
              @click="addOrUpdateHandle(scope.row.categoryId)">修改</el-button>
            <el-button v-if="isAuth('prod:category:delete')" type="danger" size="small"
              @click="deleteHandle(scope.row.categoryId)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
>>>>>>> origin/netbook
  </div>
</template>

<script>
<<<<<<< HEAD
export default {

}
</script>

<style>

</style>
=======
import { Image } from 'element-ui';
import AddOrUpdate from './category-add-or-update.vue'
import { treeDataTranslate } from '@/utils'
export default {
  data() {
    return {
      dataForm: {},
      dataList: [],
      dataListLoading: false,
      addOrUpdateVisible: false
    }
  },
  components: {
    AddOrUpdate
  },
  created() {
    this.getDataList()

  },
  methods: {
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true
      this.$http({
        url: this.$http.adornUrl('/prod/category/table'),
        method: 'get',
        params: this.$http.adornParams()
      }).then(({ data }) => {
        this.dataList = treeDataTranslate(data, 'categoryId')
        this.dataListLoading = false
      })
    },
    // 新增 / 修改
    addOrUpdateHandle(id) {
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(id)
      })
    },
    // 删除
    deleteHandle(id) {
      this.$confirm(`确定对[id=${id}]进行[删除]操作?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: this.$http.adornUrl(`/prod/category/info${id}`),
          method: 'delete',
          data: this.$http.adornData()
        }).then(({ data }) => {
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.getDataList()
            }
          })
        })
      })
    }
  }
}
</script>
>>>>>>> origin/netbook
